{ open Parser } (* Gets the token types *)

rule token = parse
	[ ' ' '\t' '\r' '\n'] { token lexbuf }   (* Whitespace *)
	| "/*"     { comment lexbuf } (* Comments *)
	| '('      { LPAREN } 
	| ')'      { RPAREN }
	| '{'      { LBRACE } 
	| '}'      { RBRACE }
	| '['      { LBRACKET }
	| ']'      { RBRACKET }
	| ';'      { SEMI } 
	| ','      { COMMA }
	| '.'      { DOT }
	| '+'      { PLUS } 
	| '-'      { MINUS }
	| '*'      { TIMES } 
	| '/'      { DIVIDE }
	| '%'      { MOD }
	| "+="     { PLUSEQ }
	| "-="     { MINUSEQ }
	| "*="     { TIMESEQ }
	| "/="     { DIVIDEEQ }
	| "%="     { MODEQ }
	| '='      { ASSIGN } 
	| '!'      { NOT }
	| "++"     { PLUSPLUS }
	| "--"     { MINUSMINUS }
	| "=="     { EQ }
	| "!="     { NEQ } 
	| '<'      { LT }
	| "<="     { LEQ } 
	| ">"      { GT }
	| ">="     { GEQ } 
	| "&&"     { AND }
	| "||"     { OR }
	| "if"     { IF } (* keywords *) 
	| "else"   { ELSE } 
	| "for"    { FOR }
	| "while"  { WHILE } 
	| "return" { RETURN }
	| "int"    { TYPE("int") }
	| "void"   { TYPE("void") }
	| "bool"   { TYPE("bool") }
	| "string" { TYPE("string") }
	| "list"   { TYPE("list" ) }
	| "card"   { TYPE("card") }
	| "player" { TYPE("player") }
	| "label"  { TYPE("label" ) }
	| [ 'S' 'H' 'D' 'C'] ("A" | "K" | "Q" | "J" | ['2' - '9']) as lxm { CARDLITERAL(lxm) }
	| "true"|"false" as boollit { BOOLEANLITERAL(bool_of_string boollit) }
	| '\"' [^ '\"' '\r' '\n']* '\"' as lxm { STRINGLITERAL(lxm) }
	| eof { EOF } (* End of file *)
	| ['0'-'9']+ as lxm { INTLITERAL(int_of_string lxm) } (* integers *)
	| ['a'-'z' 'A'-'Z']['a'-'z' 'A'-'Z' '0'-'9' '_']* as lxm { ID("$" ^ lxm) }
	
	and comment = parse
	"*/" { token lexbuf } (* End of Comment *)
	| _ { comment lexbuf } (* Eat everything else *)